//
//  CellOfColumn.m
//  MY Project For Sport
//
//  Created by admin on 16/2/5.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellOfColumn.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "ModelForColumn.h"
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellOfColumn ()

@property (nonatomic, retain) UILabel *labelForName;
@property (nonatomic, retain) UILabel *labelForSum;
@property (nonatomic, retain) UIImageView *imageViewForColumn;
@property (nonatomic, retain) UIButton *addButton;

@end



@implementation CellOfColumn

- (void)dealloc {

    [_labelForSum release];
    [_labelForName release];
    [_imageViewForColumn release];
    [_addButton release];

    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);
        
        [self createSubview];
        
    }


    return self;

}

- (void)createSubview {

    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    [_labelForName release];
    
    
    self.labelForSum = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForSum];
    [_labelForSum release];
    
    self.imageViewForColumn = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewForColumn];
    [_imageViewForColumn release];
    
    self.addButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:self.addButton];
    

}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.userInteractionEnabled = YES;
    
    self.imageViewForColumn.frame = CGRectMake(15 * WEIGHTT, 15 * HEIGHTT, WIDTH / 8, WIDTH / 8);
    self.imageViewForColumn.layer.cornerRadius = WIDTH / 16;
    self.imageViewForColumn.layer.masksToBounds = YES;

    self.labelForName.frame = CGRectMake(WIDTH / 8 + 35 * WEIGHTT, 15 * HEIGHTT, WIDTH - 35 * WEIGHTT - WIDTH / 8 - WIDTH / 6.3, (HEIGHT - 40 * HEIGHTT ) / 2);
  
    self.labelForSum.frame = CGRectMake(WIDTH / 8 + 35 * WEIGHTT, 25 * HEIGHTT+ (HEIGHT - 40 * HEIGHTT) / 2, WIDTH - 35 * WEIGHTT - WIDTH / 8 - WIDTH / 6.3, (HEIGHT - 40 * HEIGHTT ) / 2);

    
    
    self.addButton.frame = CGRectMake( WIDTH / 8 + 10 * WEIGHTT+ WIDTH - WIDTH / 8 - WIDTH / 6.3, HEIGHT / 4, WIDTH - 50 * WEIGHTT - WIDTH / 8 -(WIDTH - 35 * WEIGHTT - WIDTH / 8 - WIDTH / 6.3), HEIGHT / 2);
    
       [self.addButton setImage:[UIImage imageNamed:@"iconfont-tianjia"]  forState:UIControlStateNormal];
    
    [self.addButton addTarget:self action:@selector(addActiond:) forControlEvents:UIControlEventTouchUpInside];


}

- (void)addActiond:(UIButton *) button {

   // NSLog(@"没添加点击事件");

}


- (void)passModelForColumn:(ModelForColumn *)model {

    [self.imageViewForColumn sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    
    self.labelForName.text = model.title;
    self.labelForName.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    self.labelForSum.text = model.desc;
    self.labelForSum.font = [UIFont systemFontOfSize:15];
    self.labelForSum.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor lightGrayColor]);

}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
